immutable class CPX{T < $REAL_NUMBER{T}} < $CPX_NUMBER{T,CPX{T}}
****
Complex numbers.
_
Some of the algorithms are taken from: Press, Flannery, Teukolsky, and Vettering, "Numerical Recipes in C", second edition, Cambridge University Press, 1993.
_
Some of the choices of branch cut were chosen to be consistent with: Guy L. Steele, "Common Lisp, The Language", second edition, 1990, Digital Press.


Ancestors
$CPX_NUMBER{_,_} $NFE{_} $IS_EQ $STR
$NIL $IS_NIL

Descendants
CPX CPXD



Public


Readable Attributes
attr re,im:T;
**** Real and imaginary parts.
attr re,im:T;
**** Real and imaginary parts.

Writable Attributes
attr re,im:T;
**** Real and imaginary parts.
attr re,im:T;
**** Real and imaginary parts.

Features
abs: SAME
**** For conformance with $NFE
abs_squared:T
**** The square of the absolute magnitude of self.
absolute:T
**** The absolute magnitude of self. Cannot overload abs From Numerical Recipes in C, 2nd ed. p. 949.
acos:SAME
**** -i log(z + sqrt(1-z^2)) better to use: (pi/2)-asin(z) Steele p. 305.***
acosh:SAME
**** log(z+(z+1)sqrt((z-1)/(z+1))) Steele p. 308***
asin:SAME
**** -i log(iz + sqrt(1-z^2)) Steele p. 305.***
asinh:SAME
**** log(z+sqrt(1+z^2)) Steele p. 308***
atan:SAME
**** (log(1+i*y)-log(1-i*y))/(2*i) Steele p. 307.***
atanh:SAME
**** log((1+z)sqrt(1/(1-z^2))) Steele p. 308***
cis(f:T):SAME
**** Ignores self, e^i*f=cos f + i sin f . Steele p. 304.
conjugate:SAME
**** The complex conjugate of self.
cos:SAME
cosh:SAME
**** (e^z+e^(-z))/2 Steele p. 308***
create(f: FLT): SAME
create(f: FLTD): SAME
create(re,im:T):SAME
**** A complex number with real part `re' and imaginary part `im'.
create(i: INT): SAME
create_from_polar(mag,phase:T):SAME
**** A complex number with magnitude `mag' and phase `phase'.
create_real(x:T):SAME
cube:SAME
**** Self cubed
cube_root:SAME
**** The cube root of self. preliminary, but working.
div(c:SAME):SAME
**** The ratio of self and `c'. From Numerical Recipes in C, 2nd ed. p. 949.
div(f:T):SAME
**** Self div the floating point f.
exp:SAME
**** The complex exponential `e^self'.
is_eq(c: SAME): BOOL
**** Return true if the two numbers are equal
is_eq(arg: $OB): BOOL .. Included as is_eq
is_nil:BOOL
**** Return true if self is nil
is_within(r:T,c:SAME):BOOL
**** self is within a circle around c with radius r
log:SAME
**** The complex logarithm. The chosen branch is `log |z| + i phase(z)'. Same convention as Steele, p. 302.
magnitude:T
**** The absolute magnitude of self.
magnitude_squared:T
**** The square of the absolute magnitude of self.
maxval: SAME
**** Maximum values of real and imaginary part
minus(c:SAME):SAME
**** The difference of self and `c'.
negate:SAME
**** The additive inverse of self.
nil:SAME
**** Return a nil valued complex number with real and imaginary parts both nil
one: SAME
**** A unit value (real part=1, imaginary part=0)
phase:T
**** The angle part of the polar represenation of self. `-pi < res <= pi'. Also get "-pi" from a negative real part and a "-0.0" imaginary part. They say 0+0i should be +0, 0-0i should be -0, -0+0i should be +pi, and -0-0i should be -pi. Same convention as Steele, p. 303.
plus(c:SAME):SAME
**** The sum of self and `c'.
pow(c:SAME):SAME
**** self^c = exp(c*log(self))
reciprocal:SAME
**** The multiplicative inverse of self.
sign:SAME
**** If not zero, a number with same phase as self but unit magnitude. If it is, then returns self. Steele, p. 304***
sin:SAME
sinh:SAME
**** (e^z-e^(-z))/2 Steele p. 308***
sqrt:SAME
**** The square root of self. From Numerical Recipes in C, 2nd ed. p. 949. Steele, p. 302 chooses the branch cut by `e^((log z)/2)'
square:SAME
**** Self squared
str:STR
**** A string representation of self of the form "1.02+3.23i".
tan:SAME
tanh:SAME
**** (e^z-e^(-z))/(e^z+e^(-z)) Steele p. 308***
times(c:SAME):SAME
**** The product of self and `c'.
times(f:T):SAME
**** Self times the floating point c.
zero: SAME
**** A zero valued complex number

The Sather Home Page